{% extends 'common/panel.html' %}
{% block title %}{{instance.name}}{% endblock title %}
{% block panel %}

<script type="text/javascript" charset="utf-8">

    $('body').delegate( '.mos_info', 'mouseover', function(event) {
        //console.log('entering MOS mouseover event function...');
        id = $(this).attr('id');
        var text = "none";
        topRight = false;
        topMiddle = false;
        topLeft = false;
        switch(id) {
            //Nearshore Reports
            case 'info_nearshore_scenario':
                text  = "Reports the substrate, exposure, and/or ecosystem as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate, exposure, and/or ecosystem.";
                break;
            case 'info_nearshore_substrate':
                text  = "Reports the exposure and/or ecosystem by each substrate type as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available exposure and/or ecosystem.";
                break;
            case 'info_nearshore_exposure':
                text  = "Reports the substrate and/or ecosystem by each exposure type as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate and/or ecosystem.";
                break;
            case 'info_nearshore_ecosystem':
                text  = "Reports the substrate and/or exposure by each ecosystem type as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate and/or exposure.";
                break;
            //Offshore Scenario Reports
            case 'info_benthic_scenario':
                text  = "Reports the substrate, depth, and/or geomorphology as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate, depth, and/or geomorphology.";
                break;
            case 'info_benthic_substrate':
                text  = "Reports the depth and/or geomorphology by each substrate type as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available depth and/or geomorphology.";
                break;
            case 'info_benthic_depthclass':
                text  = "Reports the substrate and/or geomorphology by each depth class as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate and/or geomorphology.";
                break;
            case 'info_benthic_geomorphology':
                text  = "Reports the substrate and/or depth by each geomorphology type as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate and/or depth.";
                break;
            //Pelagic Scenario Reports
            case 'info_pelagic_scenario':
                text  = "Reports the upwelling and/or chlorophyll by type as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available upwelling and/or chlorophyll.";
                break;
            case 'info_pelagic_upwelling':
                text  = "Reports the chlorophyll type by class of upwelling as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available chlorophyll type.";
                break;
            case 'info_pelagic_chlorophyll':
                text  = "Reports the chlorophyll type by class of upwelling as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available chlorophyll type.";
                break;
            //Tidal Energy Reports
            case 'info_tidal_substrate':
                topLeft = true;
                text  = "Reports the substrate types as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate types.";
                break;
            case 'info_tidal_energy':
                topMiddle = true;
                text  = "Reports max and/or mean tidal current as a percentage of the scenario output based on parameters range chosen in Step 3 of the Scenario Wizard. Compare to minimum tidal current of 1.5 m/s (Spaulding et al. 2010).";
                break;
            case 'info_tidal_max_substrate':
                topMiddle = true;
                text  = "Reports mean tidal current as a percentage of the scenario output based on parameters range chosen in Step 3 of the Scenario Wizard. Compare to minimum tidal current of 1.5 m/s (Spaulding et al. 2010).";
                break;
            case 'info_tidal_mean_substrate':
                topMiddle = true;
                text  = "Reports mean tidal current as a percentage of the scenario output based on parameters range chosen in Step 3 of the Scenario Wizard. Compare to minimum tidal current of 1.5 m/s (Spaulding et al. 2010).";
                break;
            //Wave Energy Reports
            case 'info_wave_substrate':
                topLeft = true;
                text  = "Reports all substrate types as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate types.";
                break;
            case 'info_wave_potential':
                topRight = true;
                text  = "Reports summer and/or winter wave energy as a percentage of the scenario output.  Compare to minimum wave energy density of 10 kW/m (Spaulding et al. 2010).";
                break;
            case 'info_wave_summer':
                topMiddle = true;
                text  = "Reports substrate type by range of summer wave energy values as a percentage of the scenario output. Reports all substrate types by wind potential classes as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate types. Compare to minimum wave energy density of 10 kW/m (Spaulding et al. 2010).";
                break;
            case 'info_wave_winter':
                topMiddle = true;
                text  = "Reports substrate type by range of winter wave energy values as a percentage of the scenario output. Reports all substrate types by wind potential classes as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate types. Compare to minimum wave energy density of 10 kW/m (Spaulding et al. 2010).";
                break;
            //Wind Energy Reports
            case 'info_wind_scenario':
                text  = "Reports the substrate and/or wind potential class as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate and/or wind potential class.  Compare to minimum wind speed of 15.7 mph (NREL, 2011).";
                break;
            case 'info_wind_substrate':
                text  = "Reports all wind potential classes by substrate types as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available wind potential classes.";
                break;
            case 'info_wind_potential':
                text  = "Reports all substrate types by wind potential classes as a percentage of the scenario output area and calculates the scenario output as a percentage of the total available substrate types. Compare to minimum wind speed of 15.7 mph (NREL, 2011).";
                break;
        }
        if (topRight) {
            target_position = 'topLeft';
            tooltip_position = 'bottomLeft';
        } else if (topLeft) {
            target_position = 'topRight';
            tooltip_position = 'bottomRight';
        } else if (topMiddle) {
            target_position = 'topMiddle';
            tooltip_position = 'bottomMiddle';
        } else {
            target_position = 'rightMiddle';
            tooltip_position = 'leftMiddle';
        }
        if (text!='none') {
            $(this).qtip({
                content: text, 
                show: { 
                    delay: 0,
                    when: { event: 'mouseover' },
                    ready: true  //without this option, the browser hangs  
                },
                position: {
                    corner: {
                        target: target_position,
                        tooltip: tooltip_position
                    }
                },
                hide: { when: {event: 'mouseleave'} },
                style: { 
                    width: 300,
                    name: 'blue' 
                }
            });
            event.stopImmediatePropagation();//prevents repeated calls to delegate during repeat visits 
            //(previously, when smp reports, for example, were re-visited, delegate would get called once for each re-visit that 
            // had taken place between application refreshes)
            //(initially, this repeat-call behavior occurred for all delegate calls until img classes were made specific to app)
        } 
    });  
     
    
</script>  


    <h1>
        <img src="/media/wmm/img/multi.png"/>
        <small><small>Scenario </small></small> 
        &nbsp;&nbsp;{{instance.name}} {% if instance.unioned_geometry %}{% else %} -- Empty Geometry{% endif %}
    </h1>
    <div class="tabs">
        <ul>
            <li><a href="#Inputs"><span>Attributes</span></a></li>
            {% for scenario in instance.scenarios.all %}
                {% if scenario.has_empty_geom %}
                {% else %}
                <li><a href="{% url scenario_report instance.pk scenario.pk %}"><span>{{scenario.input_objective}} Report</span></a></li>
                {% endif %}
            {% endfor %}
            <!--
            {% if instance.overlap_geom %}
            <li><a href="{% url overlap_report instance.pk %}"><span>Overlap Report</span></a></li>
            {% endif %}
            -->
        </ul>
        <div id="Inputs">
            <ul class="metadata">
              {% if instance.user.first_name and instance.user.last_name %} 
                <li class="creator">Created By {{instance.user.first_name}} {{instance.user.last_name}}</li>
              {% else %}
                <li class="creator">Created By {{instance.user.username}}</li>
              {% endif %}
                <li class="created">Created {{instance.date_created|date:"d M, Y P"}}</li>
                <li class="modified">Modified {{instance.date_modified|date:"d M, Y P"}}</li>
                <br class="clear" />
            </ul>
            <!--
            <h2>Feature Type</h2>
                <p>Multi-Objective Scenario</p>
            -->    
            <h2>Description</h2>
                {% if instance.description %}
                <p>{{instance.description}}</p>
                {% else %}
                <p><i>No Description</i></p>
                {% endif %}
                
            <h2>Objectives</h2>     
                {% for scenario in instance.scenarios.all %}
                <p>{{scenario.input_objective}} {% if scenario.has_empty_geom %}-- <b>Empty Geometry</b>{% endif %}</p>
                <!--
                <div class="box species" id="temp">
                    <h3>Objective: </h3>
                        <div>
                            <p>{{scenario.input_objective}}</p>
                        </div>
                    <h3>Parameters</h3>
                        <div>
                            {% if 1 in scenario.input_parameter_ids %}
                            <p> Distance to Shore <= {{ scenario.input_dist_shore }} miles</p>
                            {% endif %}
                            {% if 2 in scenario.input_parameter_ids %}
                            <p> Distance to Port <= {{ scenario.input_dist_port }} miles</p>
                            {% endif %}
                            {% if 3 in scenario.input_parameter_ids %}
                            <p> Depth Range: {{scenario.input_min_depth|floatformat:0}} to {{scenario.input_max_depth|floatformat:0}} feet</p>
                            {% endif %}
                            {% if 5 in scenario.input_parameter_ids %}
                            <p> Substrates: </p>
                            <ul>
                            {% for substrate in scenario.input_substrate_names %}
                                <li> {{substrate}} </li>
                            {% endfor %}
                            </ul>
                            {% endif %}
                            {% if 6 in scenario.input_parameter_ids %}
                            <p> Depth Classes: </p>
                            <ul>
                            {% for depth_class in scenario.input_depth_class_names %}
                                <li> {{depth_class}} </li>
                            {% endfor %}
                            </ul>
                            {% endif %}
                            {% if 7 in scenario.input_parameter_ids %}
                            <p> Geomorphologies: </p>
                            <ul>
                            {% for geomorphology in scenario.input_geomorphology_names %}
                                <li> {{geomorphology}} </li>
                            {% endfor %}
                            </ul>
                            {% endif %}
                        </div>
                </div>
                -->
                {% endfor %}
            <h2>Support File</h2>
                <!--<div class="box species">-->
                <div>
                    {% if instance.support_file %}
                    <p><a href="{{instance.support_file.url}}" target="_blank">{{instance.support_filename}}</a></p>
                    {% else %}
                    <p><i>No Attachments</i></p>
                    {% endif %}
                </div>
        </div>
        
        {% if instance.done %}
        <div id="reports">
           <h3>Multipolygon with {{instance.output_geom|length}} individual polygons</h3>
           <h3>Total Area</h3>
           <p>{{ instance.output_area|floatformat }} sq. km</p>
           <h3>Mapcalc equation</h3>
           <pre>{{ instance.output_mapcalc }}</pre>
        </div>
        {% endif %}
        
        {% if instance.done %}
        {% for scenario in instance.scenarios.all %}
        <div id="{{scenario.input_objective.short_name}}_report">
            <p>{{scenario.input_objective}} Reports coming soon...</p>
        </div>
        {% endfor %}
        {% endif %}
    </div>

{% endblock panel %}
